package com.duobao.view;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.lang.reflect.Constructor;

import javax.swing.*;

import com.duobao.game.DuobaoSwingLaunch;
import com.duobao.server.Map;
import com.duobao.server.Maps;
import com.duobao.uitl.myFont;

public class ZhuangTaiPanel extends JPanel implements MouseListener{

    DuobaoSwingLaunch game;
    Map heroMap;

    JLabel shenti;
    JLabel suishen;
    JLabel xinxi;
    JLabel renwu;
    JLabel youxibangzhu;
    JLabel fanhui;
    JLabel fanhuiyouxi;
    public ZhuangTaiPanel(DuobaoSwingLaunch game, Constructor previousJPanel, int page)
    {
        this.game=game;
        this.heroMap=Maps.getMap(this.game.hero.getLocation());
        this.setLayout(new GridLayout(16,1,1,1));

        setShenti();
        setSuishen();
        setXinxi();
        setRenwu();
        setYouxibangzhu();
        setFanhui();
        setFanhuiyouxi();
    }
    public void setShenti() {
        shenti=new JLabel();
        shenti.addMouseListener(this);
        shenti.setFont(myFont.f2);
        shenti.setForeground(Color.BLUE);
        shenti.setText("<html><u>"+"身体状态"+"</u></html>");
        JPanel jp1=new JPanel();
        jp1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
        jp1.add(shenti);
        this.add(jp1);
    }
    public void setSuishen() {
        suishen=new JLabel();
        suishen.addMouseListener(this);
        suishen.setFont(myFont.f2);
        suishen.setForeground(Color.BLUE);
        suishen.setText("<html><u>"+"随身物品"+"</u></html>");
        JPanel jp1=new JPanel();
        jp1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
        jp1.add(suishen);
        this.add(jp1);
    }
    public void setXinxi() {
        xinxi=new JLabel();
        xinxi.addMouseListener(this);
        xinxi.setFont(myFont.f2);
        xinxi.setForeground(Color.BLUE);
        xinxi.setText("<html><u>"+"个人信息"+"</u></html>");
        JPanel jp1=new JPanel();
        jp1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
        jp1.add(xinxi);
        this.add(jp1);
    }
    public void setRenwu() {
        renwu=new JLabel();
        renwu.addMouseListener(this);
        renwu.setFont(myFont.f2);
        renwu.setForeground(Color.BLUE);
        renwu.setText("<html><u>"+"任务提示"+"</u></html>");
        JPanel jp1=new JPanel();
        jp1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
        jp1.add(renwu);
        this.add(jp1);
    }
    public void setYouxibangzhu() {
        youxibangzhu=new JLabel();
        youxibangzhu.addMouseListener(this);
        youxibangzhu.setFont(myFont.f2);
        youxibangzhu.setForeground(Color.BLUE);
        youxibangzhu.setText("<html><u>"+"游戏帮助"+"</u></html>");
        JPanel jp1=new JPanel();
        jp1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
        jp1.add(youxibangzhu);
        this.add(jp1);
    }
    public void setFanhui() {
        fanhui=new JLabel();
        fanhui.addMouseListener(this);
        fanhui.setFont(myFont.f2);
        fanhui.setForeground(Color.BLUE);
        fanhui.setText("<html><u>"+"返回"+"</u></html>");
        JPanel jp1=new JPanel();
        jp1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
        jp1.add(fanhui);
        this.add(jp1);
    }
    public void setFanhuiyouxi() {
        fanhuiyouxi=new JLabel();
        fanhuiyouxi.addMouseListener(this);
        fanhuiyouxi.setFont(myFont.f2);
        fanhuiyouxi.setForeground(Color.BLUE);
        fanhuiyouxi.setText("<html><u>"+"返回游戏"+"</u></html>");
        JPanel jp1=new JPanel();
        jp1.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
        jp1.add(fanhuiyouxi);
        this.add(jp1);
    }
    public String toString()
    {
        return "ZhuangTaiPanel";
    }
    public void mouseClicked(MouseEvent e) {
        // TODO Auto-generated method stub
        if(e.getSource()==shenti)
        {
            this.game.setPanel(new Shenti(this.game));
        }else if(e.getSource()==suishen)
        {
            try {
                this.game.setPanel(new Shuishen(this.game,this.getClass().getDeclaredConstructor(DuobaoSwingLaunch.class,Constructor.class,int.class),1));
            } catch (NoSuchMethodException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (SecurityException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }else if(e.getSource()==xinxi)
        {
            this.game.setPanel(new Xinxi(this.game,1));
        }else if(e.getSource()==fanhuiyouxi)
        {
            this.game.setPanel(new MainPanel(this.game, 1));
        }else if(e.getSource()==fanhui)
        {
            this.game.setPanel(new MainPanel(this.game, 1));
        }
    }

    public void mouseEntered(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    public void mouseExited(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    public void mousePressed(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    public void mouseReleased(MouseEvent e) {
        // TODO Auto-generated method stub

    }

}
